/*
 * Copyright (c)  2020,  DataPipeline
 * All rights reserved.
 *
 * Id:IOUtils.java   2020-07-18 10:51 wanglijun
 */
package cn.datacare.orm.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;

/**
 * <p>
 * Title: IOUtils
 * </p>
 * <p>
 * Description: IOUtils
 * </p>
 * <p>
 * Copyright: Copyright (c) 2020
 * </p>
 * <p>
 * Company/Department: DataPipeline
 * </p>
 *
 * @author wanglijun
 * @version 1.0
 * @since 2020-07-18 10:51
 */
public class IOUtils {
    /***
     * 日志
     */
    private static final Logger log = LoggerFactory.getLogger(IOUtils.class);

    /**
     * Quietly (no exceptions) close Closable resource. In case of error it will
     * be printed to {@link IOUtils} class logger.
     *
     * @param closeable resource to close
     */
    public static void closeQuietly(final Closeable closeable) {
        // no need to log a NullPointerException here
        if (closeable == null) {
            return;
        }

        try {
            closeable.close();
        } catch (Exception exc) {
            log.error("Unable to close resource: " + exc.getMessage(), exc);
        }
    }
}
